from selenium import webdriver
import time
import unittest

class TestUnit1(unittest.TestCase):
    # 获取浏览器的驱动
    def setUp(self):
        # 直接用变量名去定义变量可以吗
        # driver = webdriver.Chrome()
        self.driver = webdriver.Chrome()
        self.driver.maximize_window()
        self.url = "https://www.baidu.com/"
        self.driver.get(self.url)
        time.sleep(3)

    # 在百度中搜索信息-汉字
    # 测试用例的起名要用 test_
    def test_search1(self):
        self.driver.find_element_by_id("kw").send_keys("长津湖")
        self.driver.find_element_by_id("su").click()
        time.sleep(6)

    # 在百度中搜索信息-英文
    def test_search2(self):
        self.driver.find_element_by_id("kw").send_keys("Lisa")
        self.driver.find_element_by_id("su").click()
        time.sleep(6)

    # 关闭浏览器
    def tearDown(self):
        self.driver.quit()


    if __name__ =="main__":
        unittest.main()
